<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('管理')" />
</head>
<body>
<div class="wrapper">
    <form style="font-size: 12px" id="form">
        <div class="box-body">
            <div class="form-group">
                <label>名称</label>
                <input type="text" class="form-control input-sm" name="carouselName" id="carouselName" required>
            </div>
            <div class="form-group">
                <label>图片</label><br/>
                <input class="form-control input-sm" name="carouselUrl" id="url" readonly/>
                <button type="button" class="btn btn-sm btn-primary" id="browse2">浏览</button>
            </div>
            <div class="form-group">
                <label>商品ID</label>  <span style="color: red">请复制商品列表的ID，可连接到商品</span>
                <input type="text" class="form-control input-sm" name="goodsId" required>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var prefix = "/mall/carousel";
    $(function() {
        uploadImg2();
    });
    function submitHandler() {
        if ($.validate.form()) {
            var json = $.common.formToJSON('form');
            $.operate.save(prefix + '/save', json);
        }
    }

    function uploadImg2() {
        var uploader = new plupload.Uploader({
            browse_button: 'browse2',
            url: '/file/upload',
            flash_swf_url: '/plugin/plupload/Moxie.swf',
            sliverlight_xap_url: '/plugin/plupload/Moxie.swf',
            multi_selection: false,
            filters: {
                max_file_size: '100mb'
            }
        });
        uploader.init();
        uploader.bind('FilesAdded', function (uploader, files) {
            $.each(files, function (key, value) {
                //添加文件' + value.name;
            });
            uploader.start();
        });
        uploader.bind('FileUploaded', function (uploader, file, responseObject) {
            var resp = JSON.parse(responseObject.response);
            $('#url').val(resp.data);
        });
    }
</script>
</body>
</html>
